﻿

<!--********************* Part1:Jsp Head *********************-->

<%@ page contentType="text/html;charset=UTF-8"%>  
<%@ include file="/framework/head.jsp"%>

<!--********************* Part2:Java Code *********************-->
<%
	BusMaterialAccountSearchEvent event = (BusMaterialAccountSearchEvent)context.getSessionValue("BusMaterialAccountSearchEvent");
	ObjectList list = BusMaterialAccount.fetch().search(con,event);
%>

<!--********************* Part3:JavaScript Code ***************-->
<!--start 客户端脚本区域-->
<%@page import="system.base.BusMaterialAccountBusiness"%>
<%@page import="system.base.BusMaterialAccount"%>
<%@page import="system.base.Warehouse"%>
<%@page import="java.util.Vector"%>
<script language=javascript>

var list_code = "listBusMaterialAccount";

function doSearch()
{
	//SetValue("s_Id",GetValue("i_Id")); //序号
	//SetValue("s_BusTypeCode",GetValue("i_BusTypeCode")); //车型编码
	//SetValue("s_BusCategoryCode",GetValue("i_BusCategoryCode")); //车类编码
	//SetValue("s_BusTag",GetValue("i_BusTag")); //车牌号
    //SetValue("s_RepairedMoney",GetValue("i_RepairedMoney")); //维修费用
    //SetValue("s_OrderField",GetValue("i_OrderField")); //排序
    //SetValue("s_OrderDesc",getCheckBoxValues("i_OrderDesc")); //升降序
    var time = GetValue("i_Year")+GetValue("i_Month");
    //alert(time);
	//SetValue("s_RepairenTime",GetValue("i_RepairenTime")); //维修时间
    SetValue("s_WarehouseCode",GetValue("i_WarehouseCode")); //仓库编码
    SetValue("s_RepairenTime",time); //结算时间
	doCommonSearch();
}

function bizViewBusMaterialAccount(id)
{
	viewWin("<%=Config.getSrv()%>?action_code=viewBusMaterialAccount&Id="+id);
}

function doDelete()
{
	if(!hasChooseRadio("ids"))
	{
		bizMessage("删除","车辆维修材料费用");
		return false;
	}
	if(!bizConfirm("删除","车辆维修材料费用")) return false;
	SetAction("deleteBusMaterialAccount");
	frm.submit();
}

function doToAdd()
{
	SetAction("toAddBusMaterialAccount");
	frm.submit();
}

function doToUpdate()
{
	if(!checkOne("ids")) 
	{
		bizMessage("修改","车辆维修材料费用");
		return false;
	}
	SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toUpdateBusMaterialAccount");
	frm.submit();
}
function doToCopy()
{
	if(!checkOne("ids")) 
	{
		bizMessage("复制","车辆维修材料费用");
		return false;
	}
	SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toCopyBusMaterialAccount");
	frm.submit();
}

key_InitDefault();
key_RegSubmitHandler(doSearch);
</script>


<%=uiBody%>>

<%@ include file="/framework/menu.jsp"%>

<!--********************* Part4:Form  ***************-->
<form id=frm action="<%=Config.getSrv()%>" method="post">
<input type=hidden name="action_code" value="">
<input type=hidden name="Id" value="">
<input type=hidden name=sortOrder value="1">

<!--查询条件保留区域-->

<input type=hidden name="s_WarehouseCode" value="<%=event.getWarehouseCode()%>"> <!--仓库编码-->
<input type=hidden name="s_RepairenTime" value="<%=event.getRepairenTime()%>"> <!--维修时间-->


<%@ include file="/framework/list_head.jsp"%>

<br>
<!--********************* Part5:Search Area ***************-->
<%=uiSearchStart%>>
<%
	int key_tab = 1 ;
%>
    <%=uiSearchInputTR%>>
        <%=uiSearchInputTDHead%>>
            仓库选择：
        </td>
        <%=uiSearchInputTDHead%>>
            <%=SelectManager.viewWarehouseSelect(con,loginInfo.getLoginWarehouseCode(),"i_WarehouseCode","",false,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
        </td>       
    </tr>

    <%=uiSearchInputTR%>>
        <%=uiSearchInputTDHead%>>
            选择结算月份：
        </td>
        <%=uiSearchInputTDHead%>>
            <%=SelectManager.viewYearSelect(con,"i_Year","2008",false,"","-请选择-","","")%>  <%=SelectManager.viewMonthSelect(con,"i_Month","01",false,"","-请选择-","","")%>
            <input type="button" value="查询" class="buttons" onclick="doSearch();return false;">&nbsp;<input type="button" value="清空" class="buttons" onclick="doClearEvent();return false;">
        </td>       
    </tr>  

<%=uiSearchEnd%>

<!--列表标题--><%
    boolean isfirst = ((Boolean)(context.getSessionValue("isfirst"))).booleanValue();
    String menu = (String)context.getSessionValue("choice");
    Vector vec = (Vector)context.getValue(menu);
    String[] warehouseCodes = null;
    if(!isfirst && vec != null && vec.size() > 0){
        warehouseCodes = BusMaterialAccountBusiness.getStr(vec,1);//得到所有的仓库编码
        warehouseCodes = BusMaterialAccountBusiness.setStrArray(warehouseCodes);//去除重复的仓库编码
    }
%>
<%String repairTime = event.getRepairenTime(); %>
<%String year = repairTime.substring(0,4); %>
<%String month = repairTime.substring(4,6); %>
<% 
if(isfirst || repairTime == null || repairTime.equals("000000") || repairTime.equals("")){%>
    <%=UIManager.addListHeadTitle("单一公司分车型单车材料费用")%>    
<%}else{%>
    <%=UIManager.addListHeadTitle(Warehouse.getNameByCode(con,warehouseCodes[0])+"公司"+year+"年"+month+"月分车型单车材料费用")%>
<%}%>


<!--********************* Part6:List Area ***************-->

<%=uiListStart%>>
<%int index = 1 ;%>  
    <%=uiListHeadTR%>>
        <%=UIManager.addListHead("车型",index++)%>
        <%=UIManager.addListHead("车号",index++)%>
        <%=UIManager.addListHead("上月费用",index++,"num")%>
        <%=UIManager.addListHead("本月费用",index++,"num")%>
        <%=UIManager.addListHead("本年累计费用",index++,"num")%>
        <%=UIManager.addListHead("本年月平均费用",index++,"num")%>
        <%=UIManager.addListHead("去年月平均费用",index++,"num")%>
        <%=UIManager.addListHead("本月份同比",index++,"num")%>
        <%=UIManager.addListHead("本月份环比",index++,"num")%>
    <%=uiListHeadTREnd%>>
    <%if(!isfirst && vec != null && vec.size() > 0){ %>
        <%String busTypeCode[] = BusMaterialAccountBusiness.getStr(vec,2);//得到所有查询出来的车型 %>
        <%busTypeCode = BusMaterialAccountBusiness.setStrArray(busTypeCode);//取出本数组中的重复项 %>
        <%
        Vector moneyVec = new Vector();
        for(int i = 0;i < busTypeCode.length;i++){//
            String[] busTag = BusMaterialAccountBusiness.getValuesByIndexValueEquals(vec,busTypeCode[i],2,4);//得到类型对应的不重复的车牌号
            for(int j = 0;j < busTag.length;j++){%>
            <%if(j == 0){%>      
                <%=uiListDataTR[j%2]%> align=center>  
                    <%=uiListDataTD%> rowspan = "<%=busTag.length%>"><%=busTypeCode[i] %></td>
                    <%String[] moneys = BusMaterialAccountBusiness.getMoneyValues(year,month,busTag[j],warehouseCodes[0],con); %>
                    <%=uiListDataTD%>><%=busTag[j] %></td>      
                    <%=uiListDataTD%>><%=moneys[0] %></td>
                    <%=uiListDataTD%>><%=moneys[1] %></td>    
                    <%=uiListDataTD%>><%=moneys[2] %></td>
                    <%=uiListDataTD%>><%=moneys[3] %></td>   
                    <%=uiListDataTD%>><%=moneys[4] %></td>    
                    <%=uiListDataTD%>><%=moneys[6]+"("+moneys[7]+"%)" %></td>
                    <%=uiListDataTD%>><%=moneys[8]+"("+moneys[9]+"%)" %></td>      
                </tr>
                <%moneyVec.add(moneys); %>
            <%}else{%>
                <%=uiListDataTR[j%2]%> align=center>  
                    <%String[] moneys = BusMaterialAccountBusiness.getMoneyValues(year,month,busTag[j],warehouseCodes[0],con); %>
                    <%=uiListDataTD%>><%=busTag[j] %></td>      
                    <%=uiListDataTD%>><%=moneys[0] %></td>
                    <%=uiListDataTD%>><%=moneys[1] %></td>    
                    <%=uiListDataTD%>><%=moneys[2] %></td>
                    <%=uiListDataTD%>><%=moneys[3] %></td>   
                    <%=uiListDataTD%>><%=moneys[4] %></td>    
                    <%=uiListDataTD%>><%=moneys[6]+"("+moneys[7]+"%)" %></td>
                    <%=uiListDataTD%>><%=moneys[8]+"("+moneys[9]+"%)" %></td> 
                </tr> 
                <%moneyVec.add(moneys); %>
            <%}
            }%>
        <%}%>
        <%
        double[] counts = new double[]{0,0,0,0,0,0,0,0,0,0};
        for(int i = 0;i < moneyVec.size();i++){
            String[] moneys = (String[])moneyVec.get(i);
            for(int j = 0;j < 10;j++){
                counts[j] += Double.parseDouble(moneys[j]);
            }
        }
        counts = BusMaterialAccountBusiness.countMoney(counts);
        %>
            <%=uiListDataTR[0]%> align=center>  
            <%=uiListDataTD%> colspan = "2">合计:</td>    
                <%=uiListDataTD%>><%=counts[0] %></td>
                <%=uiListDataTD%>><%=counts[1] %></td>    
                <%=uiListDataTD%>><%=counts[2] %></td>
                <%=uiListDataTD%>><%=counts[3] %></td>   
                <%=uiListDataTD%>><%=counts[4] %></td>    
                <%=uiListDataTD%>><%=counts[6]+"("+counts[7]+"%)" %></td>
                <%=uiListDataTD%>><%=counts[8]+"("+counts[9]+"%)" %></td>
            </tr> 
        <%} %>
    
    

<%=uiListEnd%>


<!--********************* Part7:Action Area ***************-->
</form>


<%@ include file="/framework/foot.jsp"%>

<!--
	Author    :Benny
	FileName  :/system/base/BusMaterialAccountList.jsp
-->

